<?php
// +----------------------------------------------------------------------
// | Copyright (c) 2023 yoncron All rights reserved.
// +----------------------------------------------------------------------
// | Author: yoncron <yoncron@163.com>
// +----------------------------------------------------------------------
namespace app\service;

use app\common\Util;
use Webman\RedisQueue\Client;
use app\model\ExceptionLogsModel;

class ExceptionService
{
    public static function addLog($e,$color='#1ff042'){
        //红色 $color='#FE4A26';
        Util::send_error_msg("File:".$e->getFile()." [".$e->getLine()."]\r\nMsg:".$e->getMessage(),$color);
        //同步执行
//        ExceptionLogsModel::create(['exp'=>$e->getMessage(), 'file'=>$e->getFile(), 'line'=>$e->getLine(), 'add_time'=>time()]);
        //异步执行
        Async::Do(ExceptionLogsModel::class ,'create',['exp'=>$e->getMessage(), 'file'=>$e->getFile(), 'line'=>$e->getLine(), 'add_time'=>time()]);
    }
}